# Anthyphairesis.
We know that in antiquity, the ancients estimates $\pi$ as the fraction $22 / 7$. But why this particular fraction? Why not $31 / 10$, or $314 / 100$? Let us describe how Euclid describes how one compute the ratio of two lengths, a process called **anthyphairesis**, or "alternating subtraction".
Consider two lengths $A$ and $B$, say as given as below, how would you describe the ratio of the lengths of $A$ to $B$?
![[supplemental/---attachments/anthyphairesis-2025-10-27-23-44-28.png]]
Note that we can fit 2 copies of $B$ into $A$, with a remainder of length $C$ left over. Further, we can fit 3 copies of $C$ into $B$, with a remainder of $D$ left over. And finally we can fit 2 copies of $D$ into $C$, say with nothing left over.
Let us use this information to compute $A / B$. Note that $A = 2B + C$, so we have $$
\begin{eqnarray}
\frac{A}{B} & = & \frac{2B+C}{B} = 2 + \frac{C}{B} = 2 + \frac{1}{\left( \frac{B}{C} \right)} \\
& = & 2 + \frac{1}{\frac{3C + D}{C}} = 2 + \frac{1}{3+ \frac{D}{C}} =2 + \frac{1}{3 + \frac{1}{\left( \frac{C}{D} \right)}} \\
& = & 2 + \frac{1}{3+\frac{1}{\frac{2D}{D}}} = 2 + \frac{1}{3+\frac{1}{2}}
\end{eqnarray}
$$
Congratulations, you've discovered **continued fractions**! We can of course now work out $2 + \frac{1}{3 + \frac{1}{2}} = \frac{16}{7}$.
In some sense, the sequence of numbers $[2; 3, 2]$ describes the ratio of $A$ to $B$ in a very natural way. If this sequence terminates, then we can conclude that the resulting ratio is a rational number. And in fact, rational numbers are precisely those whose continued fraction terminates. Indeed, if $x = \frac{M}{N}$ is a rational number, then by Euclidean algorithm, we have this process terminating at their $\gcd$.
For example,
![[supplemental/---attachments/anthyphairesis-2025-10-29-18-45-48.png]]
## Continued fractions.
Take a sequence of positive integers (infinite or not), say $a_{0}, a_{1}, a_{2},\ldots$, where we also allow $a_{0}$ to be possibly zero. Then define $$
[a_{0}; a_{1}, a_{2}, a_{3}, \ldots ] = a_{0} + \frac{1}{a_{1}+ \frac{1}{a_{2}+\frac{1}{a_{3}+\cdots}}}
$$